package com.liuyc.lib.common

import android.app.Application
import java.lang.Exception

/**
 * 一些全局配置，如通过里面的 get 方法则可以获取全局 的application
 */
object AppGlobals {


    private var application: Application? = null

    fun init(application: Application){
        this.application = application
    }

    fun get(): Application? {
        if(application == null){
            try {
                application = Class.forName("android.app.ActivityThread")
                    .getMethod("currentApplication")
                    .invoke(null) as Application
            }catch (ex: Exception){
                ex.printStackTrace()
            }
        }

        return application
    }


}